<template>
  <div class="wrapper">
    <div class="header">
      <div class="login">
        <b>家庭记账系统</b>
      </div>
      <!-- 登录时前端进行验证 -->
      <el-form :model="user">
        <el-form-item prop="username">
          <el-input placeholder="请输入账号" size="medium" prefix-icon="el-icon-user" v-model="user.username"></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input placeholder="请输入密码" size="medium" prefix-icon="el-icon-lock" show-password
            v-model="user.password"></el-input>
        </el-form-item>
        <el-form-item class="btn">
          <el-button type="warning" size="small" autocomplete="off" @click="$router.push('/register')">注册</el-button>
          <el-button type="primary" size="small" autocomplete="off" @click="login">登录</el-button>
        </el-form-item>
      </el-form>
      <div class="order">
        <p>其它方式登录</p>
        <ul>
          <li>
            <a href="#">QQ登录</a>
          </li>
          <li>
            <a href="#">微信登录</a>
          </li>
          <li>
            <a href="#">手机号登录</a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import { loginUser } from '@/api/admin/user/User';
export default {
  name: "Login",
  data() {
    return {
      user: {},
    };
  },
  methods: {
    login() {
      loginUser(this.user).then(response => {
        if (response.code == 200) {
          //存储用户信息到浏览器
          localStorage.setItem("adminInfo", JSON.stringify(response.data));
          this.$router.push("/");
          this.$message.success("登录成功");
        } else {
          this.$message.error(response.message);
        }
      })
    }
  }
};
</script>

<style scoped>
li{
  list-style: none;
}
a{
  text-decoration: none;
  color: #5b5a5a;
  font-size: 14px;
}
.order p{
  text-align: center;
  font-size: 14px;
  color: #828282;
}
.order ul{
  display: flex;
  justify-content: space-around;
}
.order ul li{
  margin: 10px 0 0 10px;
  padding: 2px;
  width: 100px;
  text-align: center;
  border-right: 1px solid rgb(161, 161, 161);
}
.order ul li:last-child{
  border: none;
}
.wrapper {
  background-image: url(../../assets/img/bg.png);
  background-size: cover;
    height: 100vh; /* 根据需要调整 */
    background-position: center;
	display: flex;
}

.header {
  margin: 150px auto;
  background-color: #fff;
  width: 350px;
  height: 270px;
  padding: 20px 20px 40px 20px;
  border-radius: 10px;
}

.login {
  margin: 20px 0;
  text-align: center;
  font-size: 24px;
}

.btn {
	display: flex;
  margin: 10px 0;
  justify-content: space-around;
}
</style>
